<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>修改餐厅</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/module_form.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/page_memberAdd.css">
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<script src="__PUBLIC__/Plugins/Datepicker/WdatePicker.js"></script>
</head>

<body>
	<div class="page_header">
		<div class="tabbar">
			<ul class="tab clearfix" tabname="tab1">
				<li class="tabhover" show="tab1_0">基本信息</li>
				<li show="tab1_1">地址信息</li>
				<li show="tab1_2">优惠信息</li>
				<li show="tab1_3">详细信息</li>
				<li show="tab1_4">缩略图</li>
			</ul>
		</div>
	</div>
	<div class="page_wraper">
	<form method="post" id="restaurantAdd_form">
		<div id="tab1_0" fortab="tab1">
			<table cellpadding="0" cellspacing="0" class="module_form" width="600">
			<input type="hidden" id="id" name="id" value="{$detail.id}">
			<input type="hidden" id="solevar" name="solevar" value="{$detail.solevar}">
				<tr>
					<td class="ele_title" style="width:130px;"><label for="cardnum">餐厅中文名称：<em>*</em></label></td>
					<td class="ele_content">
						<input name="title" value="{$detail.title}"  placeholder="请输入中文名称,10个字符以内" type="text" id="title" class="form_ele_text width_200">
					</td>
					<td class="ele_title"><label for="cardnum">餐厅英文名称：<em>*</em></label></td>
					<td class="ele_content">
						<input name="entitle" value="{$detail.entitle|stripslashes=###}"  placeholder="请输入英文名称，4个单词以内" type="text" id="entitle" class="form_ele_text width_200">
					</td>
				</tr>
				<tr>
					<td class="ele_title"><label for="realname">订餐电话：<em>*</em></label></td>
					<td class="ele_content">
						<input name="tel" type="text" id="tel"  placeholder="请输入订餐电话" value="{$detail.tel}" class="form_ele_text width_200">
					</td>
					<td class="ele_title"><label for="realname">营业时间：<em>*</em></label></td>
					<td class="ele_content">
						<input name="starthours" value="{$detail.starthours}" type="text" id="starthours" class="form_ele_text width_95 Wdate"
						onfocus="WdatePicker({skin:'whyGreen',dateFmt:'H:mm'})"> -
						<input name="endhours" value="{$detail.endhours}" type="text" id="endhours" class="form_ele_text width_95 Wdate"
						onfocus="WdatePicker({skin:'whyGreen',dateFmt:'H:mm'})">
					</td>
				</tr>
				<tr>
					<td class="ele_title"><label for="realname">营业时间：<em>*</em></label></td>
					<td class="ele_content" colspan="3">
						<input name="starthours1" value="{$detail.starthours1}" type="text" id="starthours1" class="form_ele_text width_95"
						onfocus="WdatePicker({skin:'whyGreen',dateFmt:'H:mm'})" class="Wdate"> -
						<input name="endhours1" value="{$detail.endhours1}" type="text" id="endhours1" class="form_ele_text width_95"
						onfocus="WdatePicker({skin:'whyGreen',dateFmt:'H:mm'})" class="Wdate">
						如果只有一个时间段，这里可以留空不填
					</td>
				</tr>
				<tr>
					<td class="ele_title"><label for="realname">餐厅邮箱：</label></td>
					<td class="ele_content">
						<input name="email" value="{$detail.email}" placeholder="请输入邮箱地址" type="text" id="email" class="form_ele_text width_200"></td>
					<td class="ele_title"><label for="sex">经营类型：</label></td>
					<td class="ele_content">
						<select class="width_200" name="type" id="type">
							<option value="">请选择</option>
							<option value="1" <eq name="detail.type" value="1">selected</eq>>直营店</option>
							<option value="2" <eq name="detail.type" value="2">selected</eq>>加盟店</option>
						</select>
					</td>
				</tr>
				<tr>
					<td class="ele_title"><label for="iccard">提供发票：</label></td>
					<td class="ele_content" colspan="3">
						<input name="is_tigong" type="radio" value="1"
							<eq name="detail.is_tigong" value="1">checked</eq>> 是
						<input name="is_tigong" type="radio" value="2"
							<eq name="detail.is_tigong" value="2">checked</eq>> 否
					</td>
					<!-- <td class="ele_title"><label for="iccard">餐厅税点：</label></td>
					<td class="ele_content">
						<input name="point" type="text" id="point" placeholder="如：17，意味着：17%" value="{$detail.point}" class="form_ele_text width_200">
					</td> -->
				</tr>
				<tr>
					<td class="ele_title"><label for="iccard">餐厅折扣：</label></td>
					<td class="ele_content">
						<input name="coupon" type="text" id="coupon" placeholder="如：95，意味着：95折" value="{$detail.coupon}" class="form_ele_text width_200">
					</td>
					<td class="ele_title"><label for="phone">是否停业：</label></td>
					<td class="ele_content" colspan="3">
						<input name="is_tingye" type="radio" value="0" <eq name="detail.is_tingye" value="0">checked</eq>>否&nbsp;&nbsp;&nbsp;
						<input name="is_tingye" type="radio" value="1" <eq name="detail.is_tingye" value="1">checked</eq>>是
					</td>
				</tr>
				<tr>
					<td class="ele_title"><label for="iccard">餐厅星级：</label></td>
					<td class="ele_content">
						<select class="width_200" name="level" id="level">
							<option value="">请选择</option>
							
							<for start="5" end="0.1" step="-0.1" name="k" comparison="gt">
								<option value="{$k}" <eq name="detail.level" value="$k">selected</eq>>{$k}</option>
							</for>
							
						</select>
					</td>
					<td class="ele_title"><label for="iccard">是否延时：</label></td>
					<td class="ele_content">
						<input type="radio" name="is_yanshi" class="is_yanshi" value="2" <eq name="detail.is_yanshi" value="2">checked</eq>>否&nbsp;&nbsp;&nbsp;
						<input type="radio" name="is_yanshi" class="is_yanshi" value="1" <eq name="detail.is_yanshi" value="1">checked</eq>>是
						<input type="text"  name="yanshi" id="yanshi" value="{$detail.yanshi}" placeholder="时间：分钟" class="form_ele_text width_100" 
							style="display:none">
					</td>
				</tr>
				<tr>
					<td class="ele_title"><label for="phone">餐厅类型：</label></td>
					<td class="ele_content" colspan="3">
						<volist name="cuisine" id="v">
							<php>if(in_array($v['id'],$cuisineArr)){</php>
								<input name="cuisine[]" type="checkbox" id="cuisine" value="{$v.id}" checked>{$v.title}&nbsp;&nbsp;&nbsp;
							<php>}else{</php>
								<input name="cuisine[]" type="checkbox" id="cuisine" value="{$v.id}">{$v.title}&nbsp;&nbsp;&nbsp;
							<php>}</php>
						</volist>
						
					</td>
				</tr>
				<tr style="height:50px;">
					<td colspan="4"></td>
				</tr>
			</table>
		</div>
		<div id="tab1_1" fortab="tab1" class="clearfix" style="display:none;">
			<table cellpadding="0" cellspacing="0" class="module_form" width="600">
				<fieldset>
					<tr>
						<td class="ele_title"><label for="address1">所属地区：</label></td>
						<td colspan="3" class="ele_content">
							<div id="areaBox"></div>
						</td>
					</tr>
					<tr>
						<td class="ele_title"><label for="d_input">餐厅地址：</label></td>
						<td colspan="3" class="ele_content">
							城市地址：<input type="text" value="{$detail.ssxadd}" class="form_ele_text  width_250" name="ssxadd" id="ssxadd" readonly>
								   <input type="hidden" value="{$detail.enssxadd}" class="form_ele_text  width_250" name="enssxadd" id="enssxadd" readonly>
						</td>
					</tr>
					<tr>
						<td class="ele_title"><label for="d_input">&nbsp;</label></td>
						<td class="ele_content" colspan="3">
							详细地址：<input name="detail" value="{$detail.detail}" type="text" class="form_ele_text  width_300" id="address" placeholder="请输入中文详细地址">
						</td>
					</tr>
					<tr>
						<td class="ele_title"><label for="d_input">&nbsp;</label></td>
						<td class="ele_content" colspan="3">
							详细地址：<input name="endetail" value="{$detail.endetail}" type="text" class="form_ele_text  width_300" id="address" placeholder="请输入英文详细地址">
						</td>
					</tr>
					<tr>
						<td class="ele_title"><label for="d_input">标注信息点</label></td>
						<td class="ele_content" colspan="3">
							<input type="button" id="btn_lbs" data-toggle="modal" class="form_ele_submit" value="标注信息点" style="background-color:#39C">
							<input id="pointlat" name="latitude" value="{$detail.latitude}" type="text" class="form_ele_text  width_150" >
							<input id="pointlng" name="longitude" value="{$detail.longitude}" type="text" class="form_ele_text  width_150" >
						</td>
					</tr>
				</fieldset>
			</table>
		</div>
		<div id="tab1_2" fortab="tab1" class="clearfix" style="display:none;">
			<table cellpadding="0" cellspacing="0" class="module_form" width="600">
				<tr>
					<td class="ele_title width_150"><label for="remark">免费配送：</label></td>
					<td class="ele_content">
						<input type="radio" name="is_exempt" value="1" 
							<eq name="detail.is_exempt" value="1">checked</eq>>开启&nbsp;&nbsp;&nbsp;
						<input type="radio" name="is_exempt" value="2" <eq name="detail.is_exempt" value="2">checked</eq>>关闭
					</td>
				</tr>
				<tr id="exemptprice">
					<td class="ele_title width_150"><label for="remark">减免费用：</label></td>
					<td class="ele_content">
						<input type="text" name="exemptprice" value="{$detail.exemptprice}" class="form_ele_text  width_200">
					</td>
				</tr>
				<tr id="exempt">
					<td class="ele_title"><label for="realname">免配送费时间：</label></td>
					<td class="ele_content">
					
						<input type="checkbox" value="1" name="week[]"
							<php>if(in_array(1,$weekArr)){</php>checked<php>}</php>>星期一&nbsp;
						<input type="checkbox" value="2" name="week[]"
							<php>if(in_array(2,$weekArr)){</php>checked<php>}</php>>星期二&nbsp;
						<input type="checkbox" value="3" name="week[]"
							<php>if(in_array(3,$weekArr)){</php>checked<php>}</php>>星期三&nbsp;
						<input type="checkbox" value="4" name="week[]"
							<php>if(in_array(4,$weekArr)){</php>checked<php>}</php>>星期四&nbsp;
						<input type="checkbox" value="5" name="week[]"
							<php>if(in_array(5,$weekArr)){</php>checked<php>}</php>>星期五&nbsp;
						<input type="checkbox" value="6" name="week[]"
							<php>if(in_array(6,$weekArr)){</php>checked<php>}</php>>星期六&nbsp;
						<input type="checkbox" value="7" name="week[]"
							<php>if(in_array(7,$weekArr)){</php>checked<php>}</php>>星期七&nbsp;&nbsp;&nbsp;
						
						<input name="exemptbegin" value="{$detail.exemptbegin}" type="text" id="starthours" class="form_ele_text width_95"
						onfocus="WdatePicker({skin:'whyGreen',dateFmt:'H:mm'})" class="Wdate"> -
						<input name="exemptend" value="{$detail.exemptend}" type="text" id="endhours" class="form_ele_text width_95"
						onfocus="WdatePicker({skin:'whyGreen',dateFmt:'H:mm'})" class="Wdate">
					</td>
				</tr>
				<!-- <tr>
					<td class="ele_title width_150"><label for="remark">优惠信息（中文）：</label></td>
					<td class="ele_content">
						<textarea name="offers" cols="" rows="" id="remark">{$detail.offers}</textarea></td>
				</tr>
				<tr>
					<td class="ele_title width_150"><label for="remark">优惠信息（英文）：</label></td>
					<td class="ele_content">
						<textarea name="enoffers" cols="" rows="" id="remark">{$detail.enoffers}</textarea></td>
				</tr>
				<tr>
					<td class="ele_title width_150"><label for="remark">发票信息（中文）：</label></td>
					<td class="ele_content">
						<textarea name="invoice" cols="" rows="" id="remark">{$detail.invoice}</textarea></td>
				</tr>
				<tr>
					<td class="ele_title width_150"><label for="remark">发票信息（英文）：</label></td>
					<td class="ele_content">
						<textarea name="eninvoice" cols="" rows="" id="remark">{$detail.eninvoice}</textarea></td>
				</tr> -->
			</table>
		</div>
		<div id="tab1_3" fortab="tab1" class="clearfix" style="display:none;">
			<table cellpadding="0" cellspacing="0" class="module_form" width="600">
				<tr>
					<td class="ele_title width_150"><label for="remark">简介（中文）：</label></td>
					<td class="ele_content">
						<textarea name="content" cols="" rows="" id="remark">{$detail.content}</textarea></td>
				</tr>
				<tr>
					<td class="ele_title width_150"><label for="remark">简介（英文）：</label></td>
					<td class="ele_content">
						<textarea name="encontent" cols="" rows="" id="remark">{$detail.encontent|stripslashes=###}</textarea></td>
				</tr>
				<tr>
					<td class="ele_title width_150"><label for="remark">公告（中文）：</label></td>
					<td class="ele_content">
						<textarea name="service" cols="" rows="" id="remark">{$detail.service}</textarea></td>
				</tr>
				<tr>
					<td class="ele_title width_150"><label for="remark">公告（英文）：</label></td>
					<td class="ele_content">
						<textarea name="enservice" cols="" rows="" id="remark">{$detail.enservice|stripslashes=###}</textarea></td>
				</tr>
				<tr>
					<td class="ele_title width_150"><label for="remark">特别说明：</label></td>
					<td class="ele_content">
						<textarea name="information" cols="" rows="" id="information">{$detail.information}</textarea></td>
				</tr>
				<tr>
					<td colspan="4" style="height:30px;"></td>
				</tr>
			</table>
		</div>
		<div id="tab1_4" fortab="tab1" style="padding-left:8px;display:none;" class="clearfix" >
				<table cellpadding="0" cellspacing="0" class="module_form interlaceColor">
					<tr>
						<td class="ele_title"><label for="title">缩略图（4:3）：</label></td>
						<td class="ele_content" colspan="3">
							<notempty  name="thumb">
								<div class="thumb lgthumb">
									<img src="{$UPLOAD_PATH}{$thumb.fileurl}"/>
									<input type="hidden" value="{$detail.thumb.fileurl}" name="thumb_url[]" id="thumb_url">
									<input type="hidden" name="thumb_title[]" value="{$thumb.c_title}">
									<input type="hidden" name="thumb_sort[]" value="{$thumb.sort}">
								</div>
							</notempty>
							<empty name="thumb">
								<div class="thumb lgthumb">
									<img src="__PUBLIC__/Images/nothumb.jpg"/>
									<input type="hidden" value="" name="thumb_url[]" id="thumb_url">
									<input type="hidden" name="thumb_title[]" value="">
									<input type="hidden" name="thumb_sort[]" value="0">
								</div>
							</empty>							
							<iframe id="upload_frame" class="upload_frame" src="rest.php?s=FIL/Index/onefile&filetype=File&dealFun=thumb" frameborder="0"></iframe>
						</td>
					</tr>
					<tr>
						<td class="ele_title"><label for="title">场景图片（4:3）：</label></td>
						<td class="ele_content" colspan="3">
							<notempty  name="cjthumb">
								<div class="thumb cjthumb">
									<img src="{$UPLOAD_PATH}{$cjthumb.fileurl}"/>
									<input type="hidden" value="{$detail.cjthumb.fileurl}" name="cjthumb_url[]" id="cjthumb_url">
									<input type="hidden" name="cjthumb_title[]" value="{$single.c_title}">
									<input type="hidden" name="cjthumb_sort[]" value="{$single.sort}">
								</div>
							</notempty>
							<empty  name="cjthumb">
								<div class="thumb cjthumb">
									<img src="__PUBLIC__/Images/nothumb.jpg"/>
									<input type="hidden" value="" name="cjthumb_url[]" id="cjthumb_url">
									<input type="hidden" name="cjthumb_title[]" value="">
									<input type="hidden" name="cjthumb_sort[]" value="0">
								</div>
							</empty>
							
							<iframe id="upload_frame" class="upload_frame" src="rest.php?s=FIL/Index/onefile&filetype=File&dealFun=cjthumb" frameborder="0"></iframe>
						</td>
					</tr>
				</table>
		</div>
		</form>
	</div>
	<div class="page_footer pdtd10">
		<input type="button" name="submit" id="submit" value="提交数据"  class="form_ele_submit"/>
		<input type="reset" name="reset" id="reset" value="清空数据"  class="form_ele_reset"/>
	</div>
</body>
<script type="text/javascript">
	//弹出窗口全局变量
	var api = frameElement.api, W = api.opener;
	var dealSelectFile = [];
	$(function(){
		//上传缩略图（4:3）
		var UPLOAD_PATH = '{$UPLOAD_PATH}';
		window.dealSelectFile['thumb'] = function(data){
			$('#thumb_url').val(data.filekey);
			$('.lgthumb>img').attr('src',UPLOAD_PATH+data.filekey);
		}
		window.dealSelectFile['cjthumb'] = function(data){
			$('#cjthumb_url').val(data.filekey);
			$('.cjthumb>img').attr('src',UPLOAD_PATH+data.filekey);
		}
		
		//滑动门
		$('.tabbar li').click(function(){
			var tabname = $('.tabbar>ul').attr('tabname');
			$('.tabbar li').removeClass('tabhover');
			$(this).addClass('tabhover');
			
			$('div[fortab="'+tabname+'"]').hide();
			$('#'+$(this).attr('show')).show();
		});
		
		//判断是否延时，延时的话需要将延时文本框显示出来
		$('.is_yanshi').on('click',function(){
			var val = $(this).val();
			if(val==1){
				$('#yanshi').show();
			}else{
				$('#yanshi').hide();
			}
		});
		
		//判断是否延时，延时的话需要将延时文本框显示出来
		var yanshi = "{$detail.is_yanshi}";
		if(yanshi==1){
			$('#yanshi').show();
		}else{
			$('#yanshi').hide();
		}
		
		//判断是否显示免费配送内容
		var isshow = "{$detail.is_exempt}";
		if(isshow==1){
			$("#exempt").show();
			$("#exemptprice").show();
		}else{
			$("#exempt").hide();
			$("#exemptprice").hide();
		}
		
		//开启关闭优惠
		$("input[name='is_exempt']").on('click',function(){
			if($(this).val()==1){
				$("#exempt").show();
				$("#exemptprice").show();
			}else{
				$("#exempt").hide();
				$("#exemptprice").hide();
			}
		});
		
		//表格隔行换色
		$('.module_form tr:odd').addClass('odd');
		$('.module_form tr:even').addClass('even');
		
		//表单操作
		//重置
		$('.form_ele_reset').on('click',function(){
			$('#memberAdd_form').get(0).reset();
		});
		
		//设置餐厅星级的值
		$("#level").val("{$detail.level}");
		
		//提交
		$('#submit').on('click',function(){
			//通过POST直接提交表单
			//$('#memberAdd_form').get(0).submit();
			//etcommon.maskShow();
			
			var tipsObj  = windowApi.lhgdialog.tips('正在提交数据...',5,etIcon.loading);
			var postData = $('#restaurantAdd_form').serialize();
			
			//通过Ajax提交表单
			postData += '&province='+$('#area2').val();
			postData += '&city='+$('#area2').val();
			postData += '&district='+$('#area3').val();
			
			$.post("{:U('Outlet/edit')}", postData ,function(data){
					tipsObj.close();
					frameApi.close(); //关闭当前窗口
					if(data.status==1){
						windowApi.lhgdialog.tips('数据提交成功！',1,etIcon.success,function(){
							var obj = windowApi.lhgdialog.list['Outlet_index'];
							//obj.reload(obj);
							obj.content.$('.page_refresh').click();
						});
					}else{
						windowApi.lhgdialog.alert(data.info,function(){return;});
					}
				}, "json");
		});
		
		$('#btn_lbs').on('click',function(){
			var address = $('#ssxadd').val();
			var href    = "{:U('Outlet/outletLbs')}&id={$detail['id']}";
			var width   = '600px';
			var height  = '420px';
			var title   = '标注信息点';
			openDialog('Outlet_outletLbs',href,width,height,title);
		});
	});
	
	var linkage_json   = {$json|json_encode} ;
	var linkage_jsonen = {$jsonen|json_encode};
	$(function(){
		//初始值处理
		var did = '{$detail.area}';
		if(did!=''&&did!=0){
			var level = "{$row['level']}";
			$('#areaBox').html(dealInitialarea(did,'',level));
		}else{
			$('#areaBox').html(showLinkagearea(39,2,0));
		}
		$('select[name="area"]').live('change',function(){
			var nowLevel  = parseInt($(this).attr('level'));
			var nextLevel = nowLevel+1;
			var enhtml    = '';
			
			//清除自此以后的select
			$('select[name="area"]').each(function(index, element) {
				if(parseInt($(this).attr('level'))>nowLevel){
					$(this).remove();
				}
			});
			//给英文城市地址赋值
			$('select[name="area"]').each(function(index, element) {				
				var areaid = $(this).val();
				if(linkage_jsonen[areaid]){
					enhtml += linkage_jsonen[areaid][0];
				}
			});
			
			$('#ssxadd').val($('select[name="area"]').find("option:selected").text());
			$('#enssxadd').val(enhtml);
			
			$('input[name="area'+nowLevel+'"]').val($(this).val());
			//显示下一个select
			$('#areaBox').append(showLinkagearea($(this).val(),nextLevel,0));
		});
		
		//处理初始值
		function dealInitialarea(lid,result,level){
			if(lid){
				$.each(linkage_json , function(i, n){
					if(lid==i){
						result = dealInitialarea(n[1],result,(parseInt(level)-1))+''+showLinkagearea(n[1],level,i);
						return false;
					}
				});
			}
			return result;
		}
		
		//响应select改变事件
		function showLinkagearea(pid,level,nid){
			var html = ''; //最终输出的HTML
			var have = false; //是否有子词典
			html += '<select name="area" id="area'+level+'" level="'+level+'">';
			html += '<option value="0">请选择</option>';
			$.each(linkage_json , function(i, n){
				if(pid==n[1]){
					if(nid==i){
						html += '<option value="'+i+'" selected>'+n[0]+'</option>';
					}else{
						html += '<option value="'+i+'">'+n[0]+'</option>';
					}
					have = true;
				}
			});
			html += '</select>';
			html += '<input type="hidden" name="area'+level+'"/>';
			
			//没有子词典则此次输出为空
			if(!have){
				html = '';
			}
			return html;
		}
	});
</script>
</html>
